import os
import sys
import platform

OS_NAME = platform.system();
LIB_DIR=os.environ['LIB_DIR'];
BIN_DIR=os.environ['BIN_DIR'];

env=DefaultEnvironment().Clone()

SOURCES  = Glob('code_edit/*.c')+Glob('code_edit/*.cpp')+Glob('*.c')
SOURCES += Glob('scintilla/lexlib/*.cxx') + \
  Glob('scintilla/lexers/*.cxx') + Glob('scintilla/src/*.cxx') + \
  Glob('scintilla/awtk/*.cxx');

APP_CXXFLAGS = ''
if platform.system() != 'Windows':
  APP_CXXFLAGS += ' -std=c++11 '

env['CXXFLAGS'] = env['CXXFLAGS'] + APP_CXXFLAGS

EXPORT_DEF=''
if OS_NAME == 'Windows' and os.environ['TOOLS_NAME'] == '':
  EXPORT_DEF = ' /DEF:"src/code_edit.def" '

if 'BUILD_SHARED' in os.environ and os.environ['BUILD_SHARED'] == 'True':
  LIBS=['awtk'];
  LINKFLAGS=env['LINKFLAGS'] + EXPORT_DEF 
  env.SharedLibrary(os.path.join(BIN_DIR, 'code_edit'), SOURCES, LIBS=LIBS, LINKFLAGS=LINKFLAGS);
else:
  env.Library(os.path.join(LIB_DIR, 'code_edit'), SOURCES);

